﻿using System;
using System.Security.Cryptography;
using System.Text;

namespace Edge.Common.Utils
{
    public class AccountUtils
    {
        public static string CreateMD5PasswordHash(string s)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            UTF8Encoding ue = new UTF8Encoding();
            byte[] bytes = ue.GetBytes(s);

            //encrypt bytes
            byte[] hashBytes = md5.ComputeHash(bytes);

            //convert encrypted bytes back to the string (base 16)
            string hashString = "";

            for (int i = 0; i < hashBytes.Length; i++)
            {
                hashString += Convert.ToString(hashBytes[i], 16).PadLeft(2, '0');
            }

            return hashString;
        }
    }
}
